function confirmar() {
	if (confirm("Deseja Confirmar?")){
        return true;
    } else {
    	return false;
    }
}

/************************************************
* Function  : somenteNumero
* Descricao : permite somente numeros
*************************************************/
function somenteNumeros(event) {
	
    var tecla = (event) ? event.which : event.keyCode;
    
    if ((tecla > 47) && (tecla < 58)) {
    	return true;
    } else {
    	event.keyCode = 0;
		return false;
    }
}


/************************************************
 * Function  : somenteLetras
 * Descricao : permite somente letras
 *************************************************/
function somenteLetras(event) {
     
	var tecla = (event) ? event.which : event.keyCode;
        
	if ((tecla > 47) && (tecla < 58)) {
		event.keyCode = 0;
		return false;
	} else {
 		return true;
    }
}

/************************************************
 * Function  : mascaraData
 * Descricao : Mascara para Data
 *************************************************/
function mascaraData(inputData, e){

	if (document.all) { // Internet Explorer
		var tecla = event.keyCode;
	} else { //Outros Browsers
		var tecla = e.which;
	}
	
	if (tecla >= 47 && tecla < 58) { // numeros de 0 a 9 e "/"
		var data = inputData.value;
		
		if (data.length == 2 || data.length == 5) {
			data += '/';
			inputData.value = data;
		}
	} else if (tecla == 8 || tecla == 0) { // Backspace, Delete e setas direcionais(para mover o cursor, apenas para FF)
		return true;
	} else {
		return false;
	}
}

/************************************************
 * Function  : mascara
 * Descricao : Verifica Valores
 *************************************************/
function validaTecla(valores, event) {  

	var BCK=8, //backspace           
	ETR=13, //return                
	DEL=127, //delete 
	TAB=0, //tab, f5

	key,tecla; 

	if(BrowserDetect.browser == 'Firefox' && event.which) { 
		tecla=event.which; 

	} else if(BrowserDetect.browser == 'Explorer' && event.keyCode) { 
		tecla=event.keyCode; 

	} else { 
		return true; 
	}

	key=String.fromCharCode(tecla); 

	switch(tecla) { 
	case ETR: 

	case BCK: 

	case DEL: 
		
	case TAB: 

		return true; 

	default: 
		if(valores.indexOf(key)!=-1) { 
			return true; 
		} 
	} 
	return false; 
}

/************************************************
 * Function  : mascaraMoeda
 * Descricao : Formata em valor de moeda
 *************************************************/
function mascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e) {
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;

	if (whichCode == 8 || whichCode == 13 || whichCode == 127 || whichCode == 0)
		return true;
	
	key = String.fromCharCode(whichCode); // Valor para o código da Chave
	
	if (strCheck.indexOf(key) == -1)
		return false; // Chave inválida
	
	len = objTextBox.value.length;
	
	for (i = 0; i < len; i++)
		if ((objTextBox.value.charAt(i) != '0')
				&& (objTextBox.value.charAt(i) != SeparadorDecimal))
			break;
	
	aux = '';
	
	for (; i < len; i++)
		if (strCheck.indexOf(objTextBox.value.charAt(i)) != -1)
			aux += objTextBox.value.charAt(i);
	aux += key;
	len = aux.length;
	
	if (len == 0)
		objTextBox.value = '';
	
	if (len == 1)
		objTextBox.value = '0' + SeparadorDecimal + '0' + aux;
	
	if (len == 2)
		objTextBox.value = '0' + SeparadorDecimal + aux;
	
	if (len > 2) {
		aux2 = '';
		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += SeparadorMilesimo;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}
		objTextBox.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
			objTextBox.value += aux2.charAt(i);
		objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
	}
	return false;
}


/************************************************
 * Function  : isNumber
 * Descricao : Verifica se eh numerico
 *************************************************/
function isNumber(n) {
	return !isNaN(parseFloat(n)) && isFinite(n);
}

/************************************************
 * Function  : formatarComVirgulaAndPontos
 * Descricao : Formata numero para: ###.###.###,##
 *************************************************/
function formatarComVirgulaAndPontos(valor) {
	
	var isNegative = false;
	if (valor.indexOf("-") != -1) {
		isNegative = true;
		valor = valor.replace("-", "");
	}
	
	length = valor.length;
	qtdCasasMilComDecimal = (length - 2) / 3;
	qtdCasasMil = parseInt(qtdCasasMilComDecimal, 10);
		
	var novo = "";
	for (i = length, y = 0, cont = 0; i >= 0; i--, y++) {
		if (y == 3) {
			novo += ",";
		}

		if (y > 3) {
			cont++;
			if (cont == 3) {
				cont = 0;
				novo += ".";
			}
		}

		novo += valor.charAt(i);
	}
	
	if (isNegative) {
		novo += "-";
	}

	novo = reverseString(novo);
	if (length == 0) {
		novo = "0,00";
	} else if (length == 1) {
		novo = "0,0" + novo;
	} else if (length == 2) {
		novo = "0," + novo;
	}

	return novo;
}

/************************************************
 * Function  : reverseString
 * Descricao : Inverter string
 *************************************************/
function reverseString(s){
    return s.split("").reverse().join("");
}


